<!DOCTYPE HTML PUBLIC "-//ORA//DTD CD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>[Chapter 24] 24.16 java.io.File (JDK 1.0)</TITLE>
<META NAME="author" CONTENT="David Flanagan">
<META NAME="date" CONTENT="Thu Jul 31 16:21:59 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java">
<META NAME="title" CONTENT="Java in a Nutshell">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java in a Nutshell" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch24_15.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 24<br>The java.io Package</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch24_17.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=sect1>
<h2 CLASS=sect1><A CLASS="TITLE" NAME="JNUT2-CH-24-SECT-16">24.16 java.io.File (JDK 1.0)</A></h2>

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JNUT2-CH-24-SECT-16.1"></A></h3>
</DIV>

<P CLASS=para>
This class supports a platform-independent definition
of file and directory names. It also provides
methods to list the files in a directory, to check the
existence, readability, writeability, type, size, and
modification time of files and directories, to make new
directories, to rename files and directories, and to
delete files and directories. The constants defined by this
class are the platform-dependent directory and path
separator characters, available as a <tt CLASS=literal>String</tt> or
<tt CLASS=literal>char</tt>.

<P CLASS=para>
<tt CLASS=literal>getName()</tt> returns the name of the <tt CLASS=literal>File</tt> with
any directory names omitted. <tt CLASS=literal>getPath()</tt> returns the
full name of the file, including the directory name.
<tt CLASS=literal>getParent()</tt> returns the directory of the
<tt CLASS=literal>File</tt>. If the <tt CLASS=literal>File</tt> is an absolute
specification, then <tt CLASS=literal>getAbsolutePath()</tt> returns the
complete filename. Otherwise, if the <tt CLASS=literal>File</tt> is a
relative file specification, it returns the relative 
filename appended to the current working directory.

<P CLASS=para>
<tt CLASS=literal>isAbsolute()</tt> tests whether the <tt CLASS=literal>File</tt> is an
absolute specification. <tt CLASS=literal>exists()</tt>,
<tt CLASS=literal>canWrite()</tt>, <tt CLASS=literal>canRead()</tt>, <tt CLASS=literal>isFile()</tt>, and
<tt CLASS=literal>isDirectory()</tt> perform the obvious tests on the
specified <tt CLASS=literal>File</tt>. <tt CLASS=literal>length()</tt> returns the length
of the file. <tt CLASS=literal>lastModified()</tt> returns the
modification time of the file (which should be used for
comparison with other file times only, and not interpreted
as any particular time format).

<P CLASS=para>
<tt CLASS=literal>list()</tt> returns the name of all entries in a
directory that are not rejected by an optional
<tt CLASS=literal>FilenameFilter</tt>. <tt CLASS=literal>mkdir()</tt> creates a
directory. <tt CLASS=literal>mkdirs()</tt> creates all the directories in
a <tt CLASS=literal>File</tt> specification. <tt CLASS=literal>renameTo()</tt> renames a
file or directory. <tt CLASS=literal>delete()</tt> deletes a file or
directory. Note that there is no method to create a file;
that is done with a <tt CLASS=literal>FileOutputStream</tt>.

<DIV CLASS=screen>
<P>
<PRE>
public class <tt CLASS=literal>File</tt> extends Object implements Serializable {
    // <tt CLASS=literal>Public Constructors</tt>
            public <tt CLASS=literal>File</tt>(String <tt CLASS=literal>path</tt>);
            public <tt CLASS=literal>File</tt>(String <tt CLASS=literal>path</tt>, String <tt CLASS=literal>name</tt>);
            public <tt CLASS=literal>File</tt>(File <tt CLASS=literal>dir</tt>, String <tt CLASS=literal>name</tt>);
    // <tt CLASS=literal>Constants</tt>
            public static final String <tt CLASS=literal>pathSeparator</tt>;
            public static final char <tt CLASS=literal>pathSeparatorChar</tt>;
            public static final String <tt CLASS=literal>separator</tt>;
            public static final char <tt CLASS=literal>separatorChar</tt>;
    // <tt CLASS=literal>Public Instance Methods</tt>
            public boolean <tt CLASS=literal>canRead</tt>();
            public boolean <tt CLASS=literal>canWrite</tt>();
            public boolean <tt CLASS=literal>delete</tt>();
            public boolean <tt CLASS=literal>equals</tt>(Object <tt CLASS=literal>obj</tt>);  //<tt CLASS=literal> Overrides Object</tt>
            public boolean <tt CLASS=literal>exists</tt>();
            public String <tt CLASS=literal>getAbsolutePath</tt>();
        <b>1.1</b>  public String <tt CLASS=literal>getCanonicalPath</tt>() throws IOException;
            public String <tt CLASS=literal>getName</tt>();
            public String <tt CLASS=literal>getParent</tt>();
            public String <tt CLASS=literal>getPath</tt>();
            public int <tt CLASS=literal>hashCode</tt>();  //<tt CLASS=literal> Overrides Object</tt>
            public native boolean <tt CLASS=literal>isAbsolute</tt>();
            public boolean <tt CLASS=literal>isDirectory</tt>();
            public boolean <tt CLASS=literal>isFile</tt>();
            public long <tt CLASS=literal>lastModified</tt>();
            public long <tt CLASS=literal>length</tt>();
            public String[] <tt CLASS=literal>list</tt>();
            public String[] <tt CLASS=literal>list</tt>(FilenameFilter <tt CLASS=literal>filter</tt>);
            public boolean <tt CLASS=literal>mkdir</tt>();
            public boolean <tt CLASS=literal>mkdirs</tt>();
            public boolean <tt CLASS=literal>renameTo</tt>(File <tt CLASS=literal>dest</tt>);
            public String <tt CLASS=literal>toString</tt>();  //<tt CLASS=literal> Overrides Object</tt>
}
</PRE>
</DIV>

</DIV>

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JNUT2-CH-24-SECT-16.2">Passed To:</A></h3>

<P CLASS=para>
File(), 
File.renameTo(), 
FileInputStream(), 
FilenameFilter.accept(), 
FileOutputStream(), 
FileReader(), 
FileWriter(), 
RandomAccessFile(), 
ZipFile()

</DIV>

</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch24_15.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch24_17.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>java.io.Externalizable (JDK 1.1)</td>
<td width=171 align=center valign=top><a href="index/idx_0.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>java.io.FileDescriptor (JDK 1.0)</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
